package com.yiwei.zhh.activity;

import android.content.Intent;
import android.os.Bundle;
import android.os.PersistableBundle;
import android.view.View;
import android.widget.RelativeLayout;

import com.yiwei.zhh.R;
import com.yiwei.zhh.constant.Const;
import com.yiwei.zhh.event.OnSelectParentsEventMsg;
import com.yiwei.zhh.event.SelectParentEvent;
import com.yiwei.zhh.util.Util;

import org.greenrobot.eventbus.EventBus;

import java.util.HashMap;

/**
 * Created by xsooy-pc on 2017/4/21.
 */

public class SelectParentsActivity extends BaseActivity implements View.OnClickListener {

    private RelativeLayout btnFather;
    private RelativeLayout btnMother;
    private RelativeLayout btnOtherRelative;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setBaseContentView(R.layout.activity_select_parents);
        baseInitView(this, "SelectParentsActivity", Const.ViewType.ACTIVITY);
        initView();
    }

    private void initView() {
        setTitleText("你与联系人的关系");
        setBackIntent();
        btnFather = (RelativeLayout) findViewById(R.id.btn_father);
        btnMother = (RelativeLayout) findViewById(R.id.btn_mother);
        btnOtherRelative = (RelativeLayout) findViewById(R.id.btn_other_relative);
        btnFather.setOnClickListener(this);
        btnMother.setOnClickListener(this);
        btnOtherRelative.setOnClickListener(this);

        int selectedRelative = getIntent().getIntExtra(Const.KEY.SELECTED_RELATIVE, -1);
        if (selectedRelative == 0) {
            btnFather.setVisibility(View.GONE);
        } else if (selectedRelative == 1) {
            btnMother.setVisibility(View.GONE);
        }
    }

    @Override
    public void onClick(View view) {
//        HashMap<String, Object> map = new HashMap<>();
//        Intent intent = new Intent();
        switch (view.getId()) {
            case R.id.btn_father:
//                intent.putExtra(Const.KEY.SELECT_PARENTS, "父亲");
//                map.put("select", 0);
                EventBus.getDefault().post(new SelectParentEvent(0));
                break;
            case R.id.btn_mother:
//                intent.putExtra(Const.KEY.SELECT_PARENTS, "母亲");
//                map.put("select", 1);
                EventBus.getDefault().post(new SelectParentEvent(1));
                break;
            case R.id.btn_other_relative:
//                intent.putExtra(Const.KEY.SELECT_PARENTS, "其他亲戚");
//                map.put("select", 2);
                EventBus.getDefault().post(new SelectParentEvent(2));
                break;
        }
//        setResult(RESULT_OK, intent);
        finish();
    }
}
